<?php
abstract class Abstract_manager extends CI_Model implements IManagement
{
	protected $table;
	protected $config;
	protected $post_data;
	
	
	function __construct()
	{
		parent::__construct();
		$this->post_data = $_POST;
		
	}
	public function createItem()
	{
		$this->form_validation->set_message('required', '%s is verplicht');
		if($this->form_validation->run() == FALSE)
		{
			return FALSE;
		}
		else 
		{
            $this->post_data['created_on'] = date('Y-m-d H:i:s',time());
			$this->db->insert($this->table, $this->post_data);
			return TRUE;
		}
	}
	public function readItem($id)
	{
		return $this->db->get_where($this->table, array("id" => $id))->row();
	}
	public function readItems()
	{
		return $this->db->get($this->table)->result();
	}
	public function deleteItem($id)
	{
		$this->db->where('id', $id);
		$this->db->delete($this->table); 
	}
	public function updateItem($id, $alias = false)
	{
		$this->db->where('id', $id);
		$this->db->update($this->table, $this->post_data);
	}
	public function getAlias($id)
	{
		return $this->db->get_where($this->table, array("id" => $id ))->row()->alias;
	}
	
}